<!DOCTYPE html>
<html>
<head>
    <meta charset="gbk">
    <title>选择客户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" href="/general/erp4/static/layui/css/layui.css?t=1586046995308" media="all">
    <link rel="stylesheet" href="/general/erp4/static/layui/css/default.css?t=1586046995308" media="all">

</head>
<body>

<input type="text" id='cCusPPerson' style="display:none;">
<input type="text" id='cCusCode' style="display:none;">

<div class="layui-fluid" style="padding:0 2px;">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form" action="">
                        <div class="layui-form-item" >
                            <div class="layui-input-inline-sm" style="height:30px;">
                                <select name="cCCCode" lay-filter="cCCCode" lay-search>
                                    <option value="">国家</option>
                                    {volist name="list" id="vo"}
                                        <option value={$vo.cCCCode}>{$vo.cCCName}</option>
                                    {/volist}
                                </select>
                            </div>
                            <div class="layui-input-inline" style="height:30px;">
                                <input type="text" name="cCusName"  placeholder="客户全称或简称"  class="layui-input">
                            </div>
                            <div class="layui-input-inline" style="height:30px;">
                                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="subBtn">查询</button>
                                <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
                            </div>
                        </div>
                    </form>
                    <table id="tab1" lay-filter="tab1"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/general/erp4/static/layui/layui.js"></script>
<script>
    layui.use(['layer','table'], function(){
        var table = layui.table,$ = layui.$,form = layui.form ;
        var index = parent.layer.getFrameIndex(window.name);//获取弹出窗口的索引

        // // 父页面打开窗口的时候 带过来的url参数 本页面选中后回填到父页面的 input 框
        // var id = ''; //回填的客户Id
        // var text = ''; //回填的客户名称
        // var customer_short= '';//回填客户简称

        // var yw = ''; //回填的业务员ID
        // var ywtext = ''; //回填的业务员名称

        var zhangTao = '';//根据不同的账套链接不同的数据库

        //table 表格初始化
        var tab1 = table.render({
            elem: '#tab1'
            ,url: '/general/guojigang/public/index/delivery/ajaxCustomerList'
            ,cols: [[
                {field:'cCusCode', title: '编码', width:136,hide:'', sort: true, fixed: 'left'}
                ,{field:'cCusAbbName', title: '简称',event:'', sort: true}
                ,{field:'cCCName', title: '国家/省份', width:100,event:'', sort: true,hide:''}
                ,{field:'cCusName', title: '名称',event:'', sort: true}
                ,{field:'cCusPPerson', title: '业务员', width:126,event:'',hide:'true',sort: true}
                ,{field:'cPersonName', title: '业务员', width:100,event:'', sort: true}

                ,{type:'radio', title: '', width:80,event:'', align: 'center'}
            ]]
            ,response: {
                statusName: 'status'
                ,statusCode: 200
                ,msgName: 'msg'
                ,countName: 'count'
                ,dataName: 'data'
            }
            ,page: true
            ,where:{
                zhangTao:zhangTao
            }
        });

        //监听提交
        form.on('submit(subBtn)', function(data){
            tab1.reload({
                where:data.field
                ,page: {
                    curr: 1
                }
            })
            return false;
        });

        // 监听选择
        table.on('radio(tab1)', function(obj){
            var data = obj.data;
            // if(ywtext &&!data.cPersonName){
            //     layer.alert('请维护业务员');
            //     return;
            // }
            // parent.layui.$('#customer_name').val(data.cCusCode);
            parent.layui.$('#customer_name').val(data.cCCName +'/'+data.cCusAbbName);
            // parent.layui.$('#'+customer_short).val(data.cCusAbbName);
            // parent.layui.$('#'+ywtext).val(data.cPersonName);
            // parent.layui.$('#'+yw).val(data.cCusPPerson);
            parent.layer.close(index);//关闭弹出窗口
        });

        // 双击选择
        table.on('rowDouble(tab1)', function(obj){
            var data = obj.data;
            // if(ywtext && !data.cPersonName){
            //     layer.alert('请维护业务员');
            //     return;
            // }
            parent.layui.$('#customer_name').val(data.cCCName +'/'+data.cCusAbbName);
            // parent.layui.$('#'+text).val(data.cCCName +'/'+data.cCusAbbName);
            // parent.layui.$('#'+customer_short).val(data.cCusAbbName);
            // parent.layui.$('#'+ywtext).val(data.cPersonName);
            // parent.layui.$('#'+yw).val(data.cCusPPerson);
            parent.layer.close(index);//关闭弹出窗口
        });

    });
</script>

</body>
</html>


